package br.com.trabalho4.view;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import br.com.trabalho4.model.swing.JPaintPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.border.BevelBorder;
import javax.swing.JTextField;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class MainWindow {

	private JFrame frameTrabalho;
	
	private JPaintPanel jPaintPanel;
	private JMenu mnArquivo;
	private JMenu mnEditar;
	private JPanel panelFooter;
	private JPanel panelFooter_1;
	
	private JMenuItem menuAbrir;
	private JMenuItem menuConfiguraes;
	private JTextField textFieldZoom;
	private JSlider sliderZoom;

//	/**
//	 * Launch the application.
//	 */
//	public static void main(String[] args) {
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
//					MainWindow window = new MainWindow();
//					window.frame.setVisible(true);
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
//	}

	/**
	 * Create the application.
	 */
	public MainWindow() {
		setSystemLookAndFeel();
		initialize();
	}
	
	private void setSystemLookAndFeel() {
		try {
	        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	    } 
	    catch (UnsupportedLookAndFeelException e) {
	    	e.printStackTrace();
	    }
	    catch (ClassNotFoundException e) {
	    	e.printStackTrace();
	    }
	    catch (InstantiationException e) {
	    	e.printStackTrace();
	    }
	    catch (IllegalAccessException e) {
	    	e.printStackTrace();
	    }
	}
	
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frameTrabalho = new JFrame();
		frameTrabalho.setTitle("Trabalho 4");
		frameTrabalho.setBounds(100, 100, 450, 300);
		frameTrabalho.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		jPaintPanel = new JPaintPanel(); 
		frameTrabalho.getContentPane().add(jPaintPanel);
		
		panelFooter = new JPanel();
		panelFooter.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
		frameTrabalho.getContentPane().add(panelFooter, BorderLayout.SOUTH);
		panelFooter.setLayout(new BorderLayout(0, 0));
		
		panelFooter_1 = new JPanel();
		panelFooter.add(panelFooter_1, BorderLayout.EAST);
		
		sliderZoom = new JSlider();
		sliderZoom.setMinorTickSpacing(1);
		sliderZoom.setMajorTickSpacing(1);
		sliderZoom.setValue(1);
		sliderZoom.setMaximum(5);
		sliderZoom.setMinimum(1);
		panelFooter_1.add(sliderZoom);
		
		textFieldZoom = new JTextField();
		textFieldZoom.setBackground(Color.WHITE);
		textFieldZoom.setHorizontalAlignment(SwingConstants.CENTER);
		textFieldZoom.setText("50%");
		textFieldZoom.setEditable(false);
		panelFooter_1.add(textFieldZoom);
		textFieldZoom.setColumns(5);
		
		JMenuBar menuBar = new JMenuBar();
		frameTrabalho.setJMenuBar(menuBar);
		
		mnArquivo = new JMenu("Arquivo");
		menuBar.add(mnArquivo);
		
		menuAbrir = new JMenuItem("Abrir...");
		mnArquivo.add(menuAbrir);
		
		mnEditar = new JMenu("Editar");
		menuBar.add(mnEditar);
		
		menuConfiguraes = new JMenuItem("Configura\u00E7\u00F5es");
		mnEditar.add(menuConfiguraes);
		
		frameTrabalho.setVisible(true);
	}
	
	public JFrame getFrameTrabalho() {
		return frameTrabalho;
	}
	
	public JPaintPanel getJPaintPanel() {
		return jPaintPanel;
	}
	
	public JMenuItem getMenuAbrir() {
		return menuAbrir;
	}
	
	public JTextField getTextFieldZoom() {
		return textFieldZoom;
	}

	public JSlider getSliderZoom() {
		return sliderZoom;
	}
}
